package com.pr.makfilm.dao.impl;

import com.pr.makfilm.dao.IRowHeaderDao;
import com.pr.makfilm.domain.Room;
import com.pr.makfilm.domain.RowHeader;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by p.radomski on 23.01.14.
 */
@Repository(RowHeaderDaoImpl.BEAN_NAME)
public class RowHeaderDaoImpl extends AbstractDaoImpl<RowHeader> implements IRowHeaderDao
{
   public static final String BEAN_NAME = "rowHeaderDao";

   @Override
   public List<RowHeader> getByRoom(Room room)
   {
      Criteria criteria = createCriteria();
      criteria.add(Restrictions.eq(RowHeader.FIELD_ROOM, room));
      criteria.addOrder(Order.asc(RowHeader.FIELD_ROW));
      return criteria.list();
   }
}
